//
//  ZFBBusinessCell.m
//  支付宝口碑
//
//  Created by heima on 16/6/22.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "ZFBBusinessCell.h"
#import "ZFBLevelView.h"

@interface ZFBBusinessCell ()

/**
 *  图片名
 */
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
/**
 *  商店名称
 */
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
/**
 *  人均消费
 */
@property (weak, nonatomic) IBOutlet UILabel *averagePriceLabel;
/**
 *  距离
 */
@property (weak, nonatomic) IBOutlet UILabel *distanceLabel;
/**
 *  折扣信息
 */
@property (weak, nonatomic) IBOutlet UILabel *discountLabel;
/**
 *  折扣值
 */
@property (weak, nonatomic) IBOutlet UILabel *offNumLabel;
/**
 *  星级评价
 */
@property (weak, nonatomic) IBOutlet ZFBLevelView *levelView;
@property (weak, nonatomic) IBOutlet UILabel *minus;

@end

@implementation ZFBBusinessCell

// 控制器赋值过来一定会调用这个方法
// 通过这个方法把数据放在控件上
- (void)setBusiness:(ZFBBusiness *)business {
    _business = business;

    // 数据放在控件上
    self.iconView.image = [UIImage imageNamed:business.icon];
    self.nameLabel.text = business.name;
    self.averagePriceLabel.text = [NSString stringWithFormat:@"人均%zd元", business.averagePrice];
    self.distanceLabel.text = [NSString stringWithFormat:@"距离%zdm", business.distance];
    self.discountLabel.text = business.discount;
    self.offNumLabel.text = @(business.offNum).description;
    self.levelView.level = business.level;
}

// 点击cell 也会调用layout
- (void)layoutSubviews {
    [super layoutSubviews];

    self.minus.backgroundColor = [UIColor orangeColor];
}

@end
